<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<title></title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link rel="stylesheet" type="text/css" href="../../../css/mui.min.css" />
	<link rel="stylesheet" type="text/css" href="../../../css/pages/carSharing.css" />
</head>

<body>
	<div id="app" class="content">
		<div class="data">
			<div class="portrait m-b-15">
				<img :src="detailData.icon || '../../../images/user/moren.png' " >
			</div>
			<div class="name font-16 font-c-14" v-text="detailData.periNickname || '小区住户' "></div>
			<div class="font-12 font-c-7f">发布于 {{detailData.carCD | timeago}}</div>
			<div class="desc">
				<div class="icon">{{detailData.carType==1?'我是车主':'我是乘客'}}</div>
				<div>
					<span class="font-14 font-c-14 m-t-10" style="font-weight: bold;">出发时间</span>
					<span class="font-14 font-c-14 m-t-10" v-text="detailData.carSetoffTime"></span>
				</div>
				<div class="m-t-10">
					<span class="font-14 font-c-14 m-t-10" style="font-weight: bold;">起始地点</span>
					<span class="font-14 font-c-14 m-t-10">
						{{detailData.carStartLocation}}-{{detailData.carEndLocation}}
					</span>
				</div>

			</div>
			<div class="remark m-t-15">
				<div class="icon m-b-10">
					<img src="../images/laba.png">
				</div>
				<div class="text" v-text="detailData.carRemarks"></div>
			</div>
		</div>

		<div class="car-desc" v-if="detailData.carType==1">
			<div>
				<span class="font-c-min" style="font-weight: bold;">车牌号：</span>
				<span class="font-c-14" v-text="detailData.vehmNumberPlate"></span>
			</div>
			<div>
				<span class="font-c-min" style="font-weight: bold;">车名称：</span>
				<span class="font-c-14" v-text="detailData.vehmName"></span>
			</div>
			<div>
				<span class="font-c-min" style="font-weight: bold;">车颜色：</span>
				<span class="font-c-14" v-text="detailData.vehmColour"></span>
			</div>
		</div>

		<div class="ipone-btn" @click="iponeClick">
			联系他/拨打电话
		</div>

	</div>
	<script src="../../../js/Width.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../../js/vue.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../../js/Util.js" type="text/javascript" charset="utf-8"></script>
	<script src="https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js"></script>
	<script type="text/javascript">
		mui.init()
		mui.plusReady(function () {
			if (!mui.os.android) {
				FastClick.attach(document.body);
			}
			var self = plus.webview.currentWebview(); 
			app.carID = self.carID;
			if(self.isDelete == 1) {
				self.setStyle({
					titleNView: {
						buttons: [{
							text: "删除",
							color: '#4FA7E6',
							float: 'right',
							fontSize: '16px',
							onclick: app.onDelete
						}]
					}
				})
			}
			GetCarpoolDetails(self.carID)
		})
		var app = new Vue({
			el: "#app",
			data: {
				carID: '',
				detailData: {}
			},
			filters: {
				timeago: function (value) {
					return Util.timeago(value)
				}
			},
			methods: {
				iponeClick: function () {
					var carPhone = this.detailData.carPhone
					var periNickname = this.detailData.periNickname
					plus.nativeUI.confirm("您要给" + periNickname + "打电话吗？", function (e) {
						if (e.index == 0) {
							plus.device.dial(carPhone, false);
						}
					})
				},
				onDelete() {
					var that = this
					var carID = this.carID
					plus.nativeUI.confirm("是否确认删除？",function(e){
						if(e.index==0){
							that.isdelete(carID)
						}
					})
				},
				isdelete(carID) {
					mui.post(Util.HTTP + 'api/Carpool/DeleteCarpool',{
						carID: carID
					},function(res){
						mui.toast(res.message)
						if(res.code==1001){
							setTimeout(function(){
								mui.back()
								var list = plus.webview.currentWebview().opener();
								//触发列表界面的自定义事件（refresh）,从而进行数据刷新
								mui.fire(list, 'onDelete');
								//返回true，继续页面关闭逻辑
								return true;
							},1000)
						}
					})
				}
			}
		})

		function GetCarpoolDetails(carID) {
			mui.post(Util.HTTP + 'api/Carpool/GetCarpoolDetails', {
				carID: carID
			}, function (res) {
				if (res.code == 1001) {
					app.detailData = res.data
				} else {
					mui.toast(res.message)
				}
			})
		}
	</script>
</body>

</html>
